#include <bits/stdc++.h>
#define ps putchar(' ')
#define pe putchar('\n')
#define int long long
#define ls p << 1
#define rs p << 1 | 1
#define mid ((l + r) >> 1)
using namespace std;
inline int read()
{
    int ans = 0, f = 0;
    char c = getchar();
    while (!isdigit(c))
        f |= c == '-', c = getchar();
    while (isdigit(c))
        ans = (ans << 3) + (ans << 1) + c - 48, c = getchar();
    return f ? -ans : ans;
}
void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + 48);
}
const int N = 2e3 + 5;
int n, m, k;
string s;
signed main()
{
    freopen("copy.in", "r", stdin);
    freopen("copy.out", "w", stdout);
    k = read(), m = read();
    cin >> s, n = read();
    while (n--)
    {
        int l = read(), r = read(), x = read();
        string t;
        for (int i = 0; i < x; ++i)
            t += s[i];
        for (int i = l; i < r; ++i)
            t += s[i];
        for (int i = x; i < s.size(); ++i)
            t += s[i];
        s = "";
        for (int i = 0; i < t.size() && i < m; ++i)
            s += t[i];
    }
    for (int i = 0; i < k; ++i)
        putchar(s[i]);
    return 0;
}